#ifndef DATABASECONNECTION_H
#define DATABASECONNECTION_H

#include <QObject>
#include <QSqlDatabase>
#include <QString>
#include <QMap>

class DatabaseConnection : public QObject
{
    Q_OBJECT

public:
    explicit DatabaseConnection(QObject *parent = nullptr);
    ~DatabaseConnection();

    bool connect(const QString &driver, const QString &host, const QString &database, 
                 const QString &username, const QString &password, int port = -1);
    void disconnect();
    bool isConnected() const;
    
    QSqlDatabase database() const;
    QString connectionName() const;
    
    static QStringList supportedDrivers();

private:
    QSqlDatabase m_database;
    QString m_connectionName;
    static QMap<QString, QString> m_driverMap;
};

#endif // DATABASECONNECTION_H